var orderdb = require('../../db/order.db')
var config = require('../../config')
var removecartitem = require("../browser/removecartitem")
var logger = require('../../logger')
var emit = require('../../emit')

function onsocket(socket,data){   
    //勾选的音效ids     
    orderdb.finishorder(data.user, data.orderid, function(err){
        if(config.debug){
            logger.log(err);
        }
        else{
            if(err){
                emit.send(socket,'finishorder', 0);
            }else{
                removecartitem.onsocket(socket, data); 
                emit.send(socket,'finishorder', 1);                
            }
        }
    });
}

module.exports = {
    onsocket
}